<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org"
      xmlns:shiro="http://www.pollix.at/thymeleaf/shiro">
<head th:include="include :: header"></head>
<body class="hold-transition skin-blue sidebar-mini">

<section class="content-header">
    <h1>工艺卡审核</h1>
</section>
<section class="content">
    <div class="row">
        <div class="col-xs-12">
            <div class="box">
                <div class="box-header">
                    <form id="queryForm" onsubmit="return false;">
                        <div class="row">
                            <div class="form-inline">
                                <div class="form-group">
                                    <label for="query-proCode">项目编号</label>
                                    <input id="query-proCode" type="text" name="proCode" class="form-control"
                                           placeholder="请输入项目编号">
                                </div>
                                <div class="form-group">
                                    <label for="query-proName">项目名称</label>
                                    <input id="query-proName" type="text" name="proName" class="form-control"
                                           placeholder="请输入项目名称">
                                </div>
                                <div class="form-group">
                                    <label for="query-special">类型</label>
                                    <select id="query-special" class="form-control" name="special">
                                        <option value="" selected>请选择</option>
                                        <option th:each="type : ${specials}" th:value="${type.name}"
                                                th:text="${type.name}"></option>
                                    </select>
                                </div>
                                <div class="form-group">
                                    <label for="query-part">部分</label>
                                    <input id="query-part" type="text" name="part" class="form-control"
                                           placeholder="请输入部分">
                                </div>
                                <!--<div class="form-group">
                                    <label for="query-status">状态</label>
                                    <select id="query-status" class="form-control" name="isQuota">
                                        <option value="">请选择</option>
                                        <option value="1" selected>待转定额</option>
                                        <option value="2">部分转定额</option>
                                        <option value="3">已转定额</option>
                                    </select>
                                </div>-->
                                <div class="form-group">
                                    <label for="query-isCraSheetStatus">审核状态</label>
                                    <select id="query-isCraSheetStatus" class="form-control" name="isCraSheetStatus">
                                        <option value="">请选择</option>
                                        <option value="0" selected>未审核</option>
                                        <option value="1">已审核</option>
                                    </select>
                                </div>
                                <!--<div class="form-group">
                                    <label for="query-createName">工艺员</label>
                                    <input id="query-createName" type="text" name="createName" class="form-control"
                                           placeholder="请输入工艺员">
                                </div>
                                <div class="form-group">
                                    <label for="query-branchName">工艺科室</label>
                                    <input id="query-branchName" type="text" name="branchName" class="form-control"
                                           placeholder="请输入工艺科室">
                                </div>-->
                                <div class="form-group">
                                    <label for="query-startTime">日期</label>
                                    <input id="query-startTime" type="text" class="form-control datepicker" name="startTime"
                                           readonly="readonly"/>
                                    <label for="query-endTime"> 至 </label>
                                    <input id="query-endTime" type="text" class="form-control datepicker" name="endTime"
                                           readonly="readonly"/>
                                </div>
                                <button type="button" class="btn btn-success" id="btn-search"
                                        onclick="js.table.search(table)">
                                    <span class="Bold">搜索</span>
                                </button>
                            </div>
                        </div>
                    </form>
                </div>
                <div class="box-body">
                    <table id="bootstrap-table"></table>

                    <form id="queryForm2" onsubmit="return false;" style="display: none">
                        <div class="row">
                            <div class="form-inline">
                                <div class="form-group">
                                    <label for="query2-proCode">项目编号</label>
                                    <input id="query2-proCode" type="text" name="proCode" class="form-control">
                                </div>
                                <div class="form-group">
                                    <label for="query2-special">类型</label>
                                    <select id="query2-special" class="form-control" name="special">
                                        <option value="" selected>请选择</option>
                                        <option th:each="type : ${specials}" th:value="${type.name}"
                                                th:text="${type.name}"></option>
                                    </select>
                                </div>
                                <div class="form-group">
                                    <label for="query2-part">部分</label>
                                    <input id="query2-part" type="text" name="part" class="form-control">
                                </div>
                               <!-- <div class="form-group">
                                    <label for="query2-status">状态</label>
                                    <select id="query2-status" class="form-control" name="status">
                                        <option value="">请选择</option>
                                        &lt;!&ndash;<option value="1" selected>待提交</option>&ndash;&gt;
                                        <option value="2" selected>未转定额</option>
                                        <option value="3">已转定额</option>
                                        &lt;!&ndash;<option value="4">已转出</option>&ndash;&gt;
                                    </select>
                                </div>
                                <div class="form-group">
                                    <label for="query2-isCheck">审核状态</label>
                                    <select id="query2-isCheck" class="form-control" name="isCheck">
                                        <option value="" selected>请选择</option>
                                        <option value="0">未审核</option>
                                        <option value="1">已审核</option>
                                    </select>
                                </div>-->
                                <!--<div class="form-group">
                                    <label for="query2-createName">工艺员</label>
                                    <input id="query2-createName" type="text" name="createName" class="form-control"
                                           placeholder="请输入工艺员">
                                </div>
                                <div class="form-group">
                                    <label for="query2-branchName">工艺科室</label>
                                    <input id="query2-branchName" type="text" name="branchName" class="form-control"
                                           placeholder="请输入工艺科室">
                                </div>-->
                                <div class="form-group">
                                    <label for="query2-startTime">日期</label>
                                    <input id="query2-startTime" type="text" class="form-control datepicker" name="startTime"
                                           readonly="readonly"/>
                                    <label for="query2-endTime"> 至 </label>
                                    <input id="query2-endTime" type="text" class="form-control datepicker" name="endTime"
                                           readonly="readonly"/>
                                </div>
                            </div>
                        </div>
                    </form>
                    <table id="bootstrap-table2"></table>

                </div>
            </div>
        </div>
    </div>
</section>
<div th:include="include :: footer"></div>
<script th:inline="javascript">

    let table, table2;

    function show(row) {
        $("#query2-proCode").val(row.proCode);
        $("#query2-special").val(row.special);
        $("#query2-part").val(row.part);
        js.table.search(table2);
    }

    /** 同意操作 */
    function success(id, bid) {
        js.modal.confirm("确认同意吗？", function () {
            js.post({
                url: ctx + "est/check/success",
                data: {id: id,bid: bid},
                success: function (result) {
                    if (result.type === web_status.SUCCESS) {
                        js.modal.success(result.msg);
                        js.table.refresh(table);
                        js.table.refresh(table2);
                    } else {
                        js.modal.warning(result.msg);
                    }
                }
            })
        })
    }

    /** 驳回 */
    function reject(id) {
        js.modal.confirm("确认驳回吗？", function () {
            js.post({
                url: ctx + "est/check/reject",
                data: {id: id},
                success: function (result) {
                    if (result.type === web_status.SUCCESS) {
                        js.modal.success(result.msg);
                        js.table.refresh(table);
                        js.table.refresh(table2);
                    } else {
                        js.modal.warning(result.msg);
                    }
                }
            })
        })
    }

    $(function () {

        /** 主表 */
        table = js.table.init({
            url: ctx + "est/check/list",
            pageSize: 5,                                       // 每页的记录行数
            columns: [
                {
                    title: '序号', field: 'id', width: '50',
                    formatter: function (value, row, index) {
                        return index + 1;
                    }
                },
                {title: "项目编号", field: 'proCode'},
                {title: "项目名称", field: 'proName',width: '260px'},
                {title: "项目数量", field: 'proNum'},
                {title: "类型", field: 'special'},
                {title: "部分", field: 'part'},
                {title: "总图号", field: 'generalDrawingNo'},
                {title: "接收时间", field: 'creatTime'},
                {title: "设计科室", field: 'sectionName'},
                {title: "工艺科室", field: 'deptName'},
                {title: "审核人", field: 'checkNames'},
                {
                    title: "操作",
                    // width: '160px',
                    formatter: function (value, row) {
                        let actions = [];
                        actions.push('<a class="btn btn-info btn-xs" href="javascript:void(0)" onclick="show(' + js.jsonStringify(row) + ')"> 查看</a>');
                        if (row.notifyStatus === 0 || row.changeNotify === 0) {
                            actions.push('<a class="btn btn-success btn-xs" href="javascript:void(0)" onclick="success(' + row.id + ',' + row.bid + ')"> 同意</a>');
                            actions.push('<a class="btn btn-danger btn-xs" href="javascript:void(0)" onclick="reject(' + row.id + ')"> 驳回</a>');
                        }

                        return actions.join('');
                    }
                }
            ]
        });

        /** 子表 */
        table2 = js.table.init({
            id: "bootstrap-table2",
            firstLoad: false,
            escape: true,
            queryForm: "queryForm2",
            url: ctx + "est/check/slaveList",
            columns: [
                {
                    title: '序号', field: 'id', width: '50',
                    formatter: function (value, row, index) {
                        return index + 1;
                    }
                },
                {title: "项目编号", field: 'proCode'},
                {title: "项目名称", field: 'proName',width: '260px'},
                {title: "项目数量", field: 'proNum'},
                {title: "类型", field: 'special'},
                {title: "部分", field: 'part'},
                {title: "图号", field: 'drawNo'},
                {title: "图名", field: 'drawName'},
                {title: "状态", field: 'status',
                    formatter: function (value, row) {
                        if (value === 1) {
                            return '<span class="badge label-inverse">待提交</span>';
                        } else if (value === 2) {
                            return '<span class="badge label-warning">待转定额</span>';
                        } else if (value === 3) {
                            return '<span class="badge label-warning">待提交二审核</span>';
                        } else if (value === 4) {
                            return '<span class="badge label-success">已提交待审</span>';
                        } else if (value === 5) {
                            return '<span class="badge label-success">已转生产</span>';
                        }
                    }
                },
                {title:"是否变更",field:'mayChange',
                    formatter: function (value,row) {
                        if(value == 0){
                            return'<span class="badge label-success">未变更</span>';
                        }else {
                            return'<span class="badge label-warning">已变更</span>';
                        }
                    }
                },
                {title: "工艺科室", field: 'branchName'},
                {title: "创建人", field: 'createNameOne'},
                {title: "提报日期", field: 'createTime'},
                {
                    title: "操作",
                    // width: '160px',
                    formatter: function (value, row) {
                        let actions = [];
                        actions.push('<a class="btn btn-info btn-xs" target="_blank" href="' + ctx + 'est/cardList/full/' + row.id + '"> 查看</a>');
                        return actions.join('');
                    }
                }
            ]
        });

    });
</script>
</body>
</html>
